package com.project.controller;

import com.github.pagehelper.PageInfo;
import com.project.bean.CheckBean;
import com.project.service.ICheckService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

/**
 * @author lyl
 * description:
 */
@RestController
@RequestMapping("check")
@Api(tags = "销售信息查询controller")
public class CheckController {
    @Autowired
    private ICheckService iCheckService;


    @GetMapping("findCheckByPage/{pageNum}/{clientName}/{startDate}/{endDate}")
    private PageInfo<CheckBean> findByPage(@PathVariable int pageNum,
                                           @PathVariable String clientName,
                                           @PathVariable String startDate,
                                           @PathVariable String endDate) {
        if ("1".equals(clientName)) {
            clientName = null;
        }
        return iCheckService.findCheckByPage(pageNum, clientName, LocalDate.parse(startDate), LocalDate.parse(endDate));
    }

    @GetMapping("findCheckById/{checkId}")
    private CheckBean findById(@PathVariable int checkId) {
        return iCheckService.findCheckById(checkId);
    }
}
